/**
 * 
 */
package com.ubo.visu.util;

import java.io.File;
import java.io.FileInputStream;
import java.io.IOException;
import java.util.Properties;

/**
 * @author saludegu
 * 
 */
public class PropertiesManager implements PropertiesConstant {

	/**
	 * Instance du singleton.
	 */
	private static volatile PropertiesManager mInstance = null;

	/**
	 * Properties.
	 */
	protected Properties mProperties;

	/**
	 * 
	 * Constructor
	 * 
	 */
	private PropertiesManager() {
		super();
		try {
			mProperties = new Properties();
			mProperties.load(new FileInputStream(new File(FILE_PATH)));
		} catch (IOException exception) {
			exception.printStackTrace();
		}
	}

	/**
	 * Getter du singleton.
	 * 
	 * @return
	 */
	public static PropertiesManager getInstance() {
		if (mInstance == null)
			mInstance = new PropertiesManager();
		return mInstance;
	}

	/**
	 * Getter d'une property.
	 * 
	 * @param propertyKey
	 * @return
	 */
	public String getProperty(String propertyKey) {
		return mProperties.getProperty(propertyKey);
	}

	/**
	 * Getter d'une property.
	 * 
	 * @param propertyKey
	 * @return
	 */
	public Integer getIntProperty(String propertyKey) {
		return Integer.parseInt(mProperties.getProperty(propertyKey));
	}

	/**
	 * Getter d'une property.
	 * 
	 * @param propertyKey
	 * @return
	 */
	public Double getDoubleProperty(String propertyKey) {
		return Double.parseDouble(mProperties.getProperty(propertyKey));
	}

}
